<template>
  <!--  <el-empty  description="款项发放，敬请期待" image-size="200"-->
  <!--            image="http://localhost:99/Public/file/空空如也.png"></el-empty>-->
  <div class="payment-main-box">
    <div class="payment-info-box">
      <span style="color: #333333;font-size: 30px;font-family: 'Adobe 黑体 Std R';">请确认收款方信息：</span>
      <el-form class="info-form" ref="form" :model="form" label-width="70px">
        <el-form-item label="项目名称">
          <el-input v-model="form.project_name" disabled></el-input>
        </el-form-item>
        <el-form-item label="收款人">
          <el-input v-model="form.name" disabled></el-input>
        </el-form-item>
        <el-form-item label="银行卡号">
          <el-input v-model="form.bankNumber" disabled></el-input>
        </el-form-item>
        <el-form-item label="所属专业">
          <el-input v-model="form.major" disabled></el-input>
        </el-form-item>
        <el-form-item label="电话">
          <el-input v-model="form.phone" disabled></el-input>
        </el-form-item>
        <el-form-item label="地址">
          <el-input v-model="form.address" disabled></el-input>
        </el-form-item>
        <el-form-item label="入学年份">
          <el-input v-model="form.enrollment" disabled></el-input>
        </el-form-item>
        <el-form-item label="是否还款">
          <el-switch v-model="form.isRefund" disabled></el-switch>
        </el-form-item>
        <el-form-item label="">
          <p class="price-sum">总计 : {{ form.price }}元</p>
        </el-form-item>
        <el-form-item>
          <el-button @click="centerDialogVisible = true" type="primary">立即发放</el-button>
          <el-dialog
              title="提示"
              :visible.sync="centerDialogVisible"
              width="30%"
              center>
            <span>您正在向：{{ form.name }}，银行卡号：{{ form.bankNumber }}。发放资金：{{ form.price }}，请再次核对信息。</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="centerDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="paymentSuccess">确 定</el-button>
            </span>
          </el-dialog>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: "ProjectPayment",
  data() {
    return {
      applyId: 0,
      centerDialogVisible: false,
      form: {
        project_name: '',
        name: '',
        bankNumber: '',
        major: '',
        phone: '',
        address: '',
        enrollment: '',
        isRefund: false,
        price: 0,
      }
    }
  },
  mounted() {
    this.applyId = this.$route.query.applyId
    this.getPaymentInfo()
  },
  methods: {
    getPaymentInfo() {
      this.$axios.get("/adminFinancial/getPaymentInfo?applyId=" + this.applyId).then(res => {
        if (res.data.code === 200) {
          this.form = res.data.data
        }
      })
    },
    paymentSuccess() {
      this.$axios.post("/adminFinancial/putPayment?applyId=" + this.applyId).then(res => {
        if (res.data.code === 200) {
          this.$message.success("资金发放成功")
          this.centerDialogVisible = false
          this.$axios.post("/message/sendMessage",{
            author: parseInt(this.$store.getters.getUser.id),
            applyId: parseInt(this.applyId),
            message: "您的申报项目："+ this.form.project_name+"，资金已发放至银行卡："+this.form.bankNumber+"，请您查收。"
          })
          this.$router.push("/adminPayment")
        }
      })
    }
  }
}
</script>

<style scoped>
.payment-main-box {
  display: flex;
  flex-direction: row;
}

.payment-info-box {
  height: 800px;
  width: 500px;
  padding-top: 15px;
  padding-left: 15px;
}

.info-form {
  margin: 20px 50px;
}

.price-sum {
  color: #023b7c;
  font-size: 24px;
  padding-top: 20px;
}
</style>